How can I match a phone number with a regex? [closed]

Posted by Zerobu on Stack Overflow See other posts from Stack Overflow or by Zerobu
Published on 2010-03-21T03:32:24Z Indexed on 2010/03/22 15:41 UTC
Read the original article Hit count: 241

Filed under:
|
|

Possible Duplicate:
A comprehensive regex for phone number validation

I would like a regular expression in this format. It Must match one of the following formats:

  • (###)###-####
  • ###-###-####
  • ###.###.####
  • ##########

Strip all whitespace. Make sure it's a valid phone number, then (if necessary) translate it to the first format listed above.

© Stack Overflow or respective owner

Related posts about perl

Related posts about regex